package bbs.utils;

import bbs.entity.dto.SysSettingDto;
import bbs.entity.po.SysSetting;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class SysCacheUtils {
    private static final String KEY_SYS = "sys_setting";
    private static final Map<String, SysSettingDto> CACHE_DATA = new ConcurrentHashMap<>();

    public static SysSettingDto getSysSetting() {
        return CACHE_DATA.get(KEY_SYS);
    }

    public static void refres(SysSettingDto dto) {
        CACHE_DATA.put(KEY_SYS, dto);
    }

    public static String eecpapeHtml(String content) {
        if (StringTools.isEmpty(content)) return content;

        content = content.replaceAll("<", "&lt;");
        content = content.replaceAll(" ", "&nbsp;");
        content = content.replaceAll("\n", "<br>");

        return content;
    }
}
